<!DOCTYPE html>
<html lang="en">

<head>
    <!-- META DATA -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->

    <!-- TITLE OF SITE -->
    <title>伯俊微后台</title>
    <!--linear icon css-->
    <link rel="stylesheet" href="assets/css/icon-font.min.css">
    <!--bootstrap.min.css-->
    <link rel="stylesheet" href="assets/css/bootstrap.min.css">
    <link rel="stylesheet" href="assets/css/search_box.css">
    <!--style.css-->
    <link rel="stylesheet" href="assets/css/style.css">
    <link rel="stylesheet" href="assets/css/isshop.css">
    <link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/4.7.0/css/font-awesome.css">


    <style>

        #shht {
            box-shadow: 0 0 7px #c8c8c8;
            display: none;
        }


    </style>
    <style>
        * {
            margin: 0;
            padding: 0;
            list-style: none;
        }

        a {
            text-decoration: none;
        }

        a:hover {
            text-decoration: none;
        }


        .tcdPageCode a {
            display: inline-block;
            color: #428bca;

            height: 25px;
            line-height: 25px;
            padding: 0 10px;
            border: 1px solid #ddd;
            margin: 0 2px;
            border-radius: 4px;
            vertical-align: middle;
        }

        .tcdPageCode a:hover {
            text-decoration: none;
            border: 1px solid #428bca;
        }

        .label-title {
            margin: 1%;
            padding-top: 2%;
        }

        .label-title div {
            float: left;
            margin-left: 2%;
        }

        .label-title input {
            border: 0;
            background-color: rgba(0, 53, 255, 0);
        }

        .label-title div:nth-child(1) {
            margin-left: 10%;

            width: 55%;
        }

        hr {
            float: left;
            margin: 1%;
            width: 100%;

            height: 1px;
        }

        .label-value {
            float: left;
            margin: 1%;
            width: 100%;
            padding: 0 1% 4% 1%;
        }

        .label-value div {
            float: left;
            margin: 1% 0 1% 4%;
            padding-left: 2%;
            background-color: #efc83938;
            border-radius: 25px;
        }

        .label-value span {
            padding-right: 5px;
        }

        .list {
            background-color: #fff;
            height: 8%;
            border-radius: 5px;
        }

        #run {
            border: 0;
            text-decoration: none;
            background: #20ac27;
            color: #f2f2f2;

            padding: 10px 20px 10px 20px;
            margin-left: 2%;
            font-size: 16px;
            font-family: 微软雅黑, 宋体, Arial, Helvetica, Verdana, sans-serif;
            font-weight: bold;
            border-radius: 3px;

            -webkit-transition: all linear 0.30s;
            -moz-transition: all linear 0.30s;
            transition: all linear 0.30s;
        }

    </style>
</head>

<body style="font-family: Helvetica Neue,Helvetica,PingFang SC,Hiragino Sans GB,Microsoft">

<div id="wrapper">

    <nav class="navbar navbar-default navbar-fixed-top">
        <div class="brand" style="overflow: hidden;width: 12.6%;">

                <h2 style="color: #fcfdfd">控制台</h2>

        </div>
        <div class="container-fluid">
            <div class="navbar-btn">
                <button type="button" class="btn-toggle-fullwidth">
                    <i class="lnr lnr-arrow-left-circle"></i>
                </button>
            </div>
            <form class="navbar-form navbar-left" style="margin-bottom: 0;">
                <div style="line-height: 50px;font-weight: bold;">
                    <a href="index.html"
                       style="display: block;float: left;padding: 0 15px;margin: 0 10px;cursor: pointer;padding-bottom: 10px;;">总览</a>
                    <a href="javascript:void(0);" id="shht-sj"
                       style="display: block;float: left;padding: 0 15px;margin: 0 10px;cursor: pointer;padding-bottom: 10px;">
                        商户后台
                        <span class="fa fa-angle-down"
                              style="font-size:25px;position: absolute;margin: 12px 0 0 2px;">  </span>
                    </a>
                    <a href="bos-config.html"
                       style="display: block;float: left;padding: 0 15px;margin: 0 10px;cursor: pointer;padding-bottom: 10px;">系统设置</a>
                    <a href="wechat-index.html"
                       style="display: block;float: left;padding: 0 15px;margin: 0 10px;cursor: pointer;padding-bottom: 10px;">微生活</a>
                </div>
            </form>
            <div id="shht"
                 style="width: 500px;height: 300px;position: absolute;top: 67px;left: 100px;background-color: #fcfdfd">

                <div style="margin-left: 180px;">
                    <h4 style=" margin: 40px 0 22px 35px; color: black; font-size: 15px;">
                        <b>会员管理</b></h4>
                    <ul style="list-style:none;font-size: 12px;margin: 20px 0 30px 35px;">
                               <li style="margin: 15px 0 0 0;"><a href="vip-wx.html">会员列表</a></li>
                        <li style="margin: 15px 0 0 0;"><a href="vip-label.html">会员标签</a></li>
                       <!-- <li style="margin: 15px 0 0 0;"><a href="#">会员列表</a></li>-->
                    </ul>
                </div>

                <div style="margin-left: 70px;margin-top: -148px;">
                    <h4 style=" margin: 62px 0 22px 35px; color: black; font-size: 15px;">
                        <b>门店管理</b></h4>
                    <ul style="list-style:none;font-size: 12px;margin: 20px 0 30px 35px;">
                         <li style="margin: 15px 0 0 0;"><a href="store.html">门店列表</a></li>
                                                               <!-- <li style="margin: 15px 0 0 0;"><a href="#">门店体系</a></li>
                         <li style="margin: 15px 0 0 0;"><a href="#">门店状态</a></li>-->
                    </ul>
                </div>
                <div style="margin-left: 70px;">
                    <h4 style=" margin: 62px 0 22px 35px; color: black; font-size: 15px;">
                        <b>营销活动</b></h4>
                    <ul style="list-style:none;font-size: 12px;margin: 20px 0 30px 35px;">
                        <li style="margin: 15px 0 0 0;"><a href="coupon-y.html">优惠券</a></li>
                        <li style="margin: 15px 0 0 0;"><a href="activity.html">活动管理</a></li>
                    </ul>
                </div>

            </div>
            <div class="navbar-menu">
                <ul class="nav navbar-nav navbar-right">

                    <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                            <!--<img src="assets/images/parson.png" class="img-circle" alt="parson-img">-->
                            <span style="font-size: 15px;color: #000;">账户信息</span>
                            <i class="icon-submenu fa fa-angle-down"></i>
                        </a>
                        <ul class="dropdown-menu">
                            <li><a href="#"><i class="lnr lnr-user"></i> <span>账户信息</span></a></li>
                            <li><a href="change-password.html"><i class="lnr lnr-cog"></i> <span>修改密码</span></a></li>
                            <li id="e-exit"><a href="#"><i class="lnr lnr-envelope"></i> <span>退出登录</span></a></li>
                        </ul>
                    </li>
                </ul>
            </div>
        </div>

    </nav>

    <div id="sidebar-nav" class="sidebar">
        <div class="sidebar-scroll">
            <h3 style="color: #ffffff;padding: 0 0 0 8%">会员标签</h3>
            <nav>
                <ul class="nav">
                    <li class="active">
                        <a href="vip-label.html">
                            <span style="padding: 0 0 0 30px;">编辑标签</span>
                        </a>
                    </li>
                </ul>
            </nav>
        </div>
    </div>
    <!--MAIN-->
    <div class="main">
        <div style="margin-left: 80%;margin-top: 1%"><input type="button" id="run" value="同步数据到微信" onclick="sync()">
        </div>
        <div style="font-size: 20px"><!--<span style="margin-left: 2%">微信标签</span>--><span
                style="margin-left: 15%">系统标签</span>
        </div>

        <!--<div id="left" style="background-color: rgb(255,255,255); padding: 1%;margin: 2%; width: 45%;float: left">

            &lt;!&ndash;<div class="list">
                <div class="label-title">
                    <div>身高</div>
                    <div><input type="button" value="删除类型"></div>
                    <div><input type="button" value="添加标签"></div>
                    <hr>
                </div>
                <div class="label-value">
                    <div><span>175-180</span><span><i class="fa fa-times"></i></span></div>
                    <div><span>180-185</span><span><i class="fa fa-times"></i></span></div>
                    <div><span>185-190</span><span><i class="fa fa-times"></i></span></div>
                    <div><span>190-195</span><span><i class="fa fa-times"></i></span></div>
                </div>
            </div>&ndash;&gt;
        </div>-->

        <div id="right"
             style="background-color: rgb(255,255,255); padding: 1%;    margin: 2% 0 0 14%;width: 65%;float: left">

            <div class="list">
                <div class="label-title">
                    <div id="bos_type_name1">属性1&nbsp;</div>
                    <div><input onclick="clikaddtags(1)" type="button" value="添加标签"></div>
                    <div><input onclick="clikModTypeName(1)" id="bos_type_med1" type="button" value="修改类别"></div>
                    <hr>
                </div>
                <div class="label-value" id="bos_type_value1">
                </div>
            </div>

            <div class="list">
                <div class="label-title">
                    <div id="bos_type_name2">属性2&nbsp;</div>
                    <div><input onclick="clikaddtags(2)" type="button" value="添加标签"></div>
                    <div><input onclick="clikModTypeName(2)" id="bos_type_med2" type="button" value="修改类别"></div>
                    <hr>
                </div>
                <div class="label-value" id="bos_type_value2">
                </div>
            </div>

            <div class="list">
                <div class="label-title">
                    <div id="bos_type_name3">属性3&nbsp;</div>
                    <div><input onclick="clikaddtags(3)" type="button" value="添加标签"></div>
                    <div><input onclick="clikModTypeName(3)" id="bos_type_med3" type="button" value="修改类别"></div>
                    <hr>
                </div>
                <div class="label-value" id="bos_type_value3">
                </div>
            </div>

            <div class="list">
                <div class="label-title">
                    <div id="bos_type_name4">属性4&nbsp;</div>
                    <div><input onclick="clikaddtags(4)" type="button" value="添加标签"></div>
                    <div><input onclick="clikModTypeName(4)" id="bos_type_med4" type="button" value="修改类别"></div>
                    <hr>
                </div>
                <div class="label-value" id="bos_type_value4">
                </div>
            </div>

            <div class="list">
                <div class="label-title">
                    <div id="bos_type_name5">属性5&nbsp;</div>
                    <div><input onclick="clikaddtags(5)" type="button" value="添加标签"></div>
                    <div><input onclick="clikModTypeName(5)" id="bos_type_med5" type="button" value="修改类别"></div>
                    <hr>
                </div>
                <div class="label-value" id="bos_type_value5">
                </div>
            </div>

            <div class="list">
                <div class="label-title">
                    <div id="bos_type_name6">属性6&nbsp;</div>
                    <div><input onclick="clikaddtags(6)" type="button" value="添加标签"></div>
                    <div><input onclick="clikModTypeName(6)" id="bos_type_med6" type="button" value="修改类别"></div>
                    <hr>
                </div>
                <div class="label-value" id="bos_type_value6">
                </div>
            </div>

            <div class="list">
                <div class="label-title">
                    <div id="bos_type_name7">属性7&nbsp;</div>
                    <div><input onclick="clikaddtags(7)" type="button" value="添加标签"></div>
                    <div><input onclick="clikModTypeName(7)" id="bos_type_med7" type="button" value="修改类别"></div>
                    <hr>
                </div>
                <div class="label-value" id="bos_type_value7">
                </div>
            </div>

            <div class="list">
                <div class="label-title">
                    <div id="bos_type_name8">属性8&nbsp;</div>
                    <div><input onclick="clikaddtags(8)" type="button" value="添加标签"></div>
                    <div><input onclick="clikModTypeName(8)" id="bos_type_med8" type="button" value="修改类别"></div>
                    <hr>
                </div>
                <div class="label-value" id="bos_type_value8">
                </div>
            </div>

            <div class="list">
                <div class="label-title">
                    <div id="bos_type_name9">属性9&nbsp;</div>
                    <div><input onclick="clikaddtags(9)" type="button" value="添加标签"></div>
                    <div><input onclick="clikModTypeName(9)" id="bos_type_med9" type="button" value="修改类别"></div>
                    <hr>
                </div>
                <div class="label-value" id="bos_type_value9">
                </div>
            </div>

            <div class="list">
                <div class="label-title">
                    <div id="bos_type_name10">属性10</div>
                    <div><input onclick="clikaddtags(10)" type="button" value="添加标签"></div>
                    <div><input onclick="clikModTypeName(10)" id="bos_type_med10" type="button" value="修改类别"></div>
                    <hr>
                </div>
                <div class="label-value" id="bos_type_value10">
                </div>
            </div>

            <div class="list">
                <div class="label-title">
                    <div id="bos_type_name11">属性11</div>
                    <div><input onclick="clikaddtags(11)" type="button" value="添加标签"></div>
                    <div><input onclick="clikModTypeName(11)" id="bos_type_med11" type="button" value="修改类别"></div>
                    <hr>
                </div>
                <div class="label-value" id="bos_type_value11">
                </div>
            </div>

            <div class="list">
                <div class="label-title">
                    <div id="bos_type_name12">属性12</div>
                    <div><input onclick="clikaddtags(12)" type="button" value="添加标签"></div>
                    <div><input onclick="clikModTypeName(12)" id="bos_type_med12" type="button" value="修改类别"></div>
                    <hr>
                </div>
                <div class="label-value" id="bos_type_value12">
                </div>
            </div>

            <div class="list">
                <div class="label-title">
                    <div id="bos_type_name13">属性13</div>
                    <div><input onclick="clikaddtags(13)" type="button" value="添加标签"></div>
                    <div><input onclick="clikModTypeName(13)" id="bos_type_med13" type="button" value="修改类别"></div>
                    <hr>
                </div>
                <div class="label-value" id="bos_type_value13">
                </div>
            </div>

            <div class="list">
                <div class="label-title">
                    <div id="bos_type_name14">属性14</div>
                    <div><input onclick="clikaddtags(14)" type="button" value="添加标签"></div>
                    <div><input onclick="clikModTypeName(14)" id="bos_type_med14" type="button" value="修改类别"></div>
                    <hr>
                </div>
                <div class="label-value" id="bos_type_value14">
                </div>
            </div>

            <div class="list">
                <div class="label-title">
                    <div id="bos_type_name15">属性15</div>
                    <div><input onclick="clikaddtags(15)" type="button" value="添加标签"></div>
                    <div><input onclick="clikModTypeName(15)" id="bos_type_med15" type="button" value="修改类别"></div>
                    <hr>
                </div>
                <div class="label-value" id="bos_type_value15">
                </div>
            </div>
        </div>

        <div id="input-tags" style="display: none;background-color: #fff;position: fixed;width: 300px;height: 100px;box-shadow: 0 0 7px #c8c8c8;text-align: center;top: 40%;left: 45%;">
            <div style="text-align: right"><span style="margin: 3%;font-size: 20px">输入名称</span><span
                    onclick="exitaddtags()" style="margin: 0 5% 0 18%;"><i class="fa fa-times"
                                                                           style="font-size: 2em"></i></span></div>
            <div style="margin: 3%"><input id="input-value" data-id="" type="text"><input id="input-but" type="button"
                                                                                          value="提交"></div>
        </div>

    </div>

    <div class="row">
        <script type="text/javascript" src="js/angular.min.js"></script>
        <script type="text/javascript" src="js/ui-bootstrap-tpls.min.js"></script>
    </div>
</div>

<div class="clearfix"></div>

<script src="js/jquery.min.js"></script>

<script src="assets/js/fontawesome-all.min.js"></script>
<script src="assets/js/bootstrap.min.js"></script>

</body>
<script src="assets/js/jq.page.js"></script>
<script>
    $("#shht-sj,#shht").hover(function () {
        // 鼠标移入时添加hover类

        $("#shht").css('display', 'inline')
    }, function () {
        // 鼠标移出时移出hover类

        $("#shht").css('display', 'none')
    });
</script>
<script>
    (function ($) {
        $.getUrlParam1 = function (name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
            var r = window.location.search.substr(1).match(reg);
            if (r != null)
                return decodeURI(r[2]);
            return null;
        }
    })(jQuery);
</script>
<script>
    var bossyn = [];
    var wxsyn = [];
    $(document).ready(
        getWXdata(), getBOSdata()
    );

    function exitaddtags() {
        $("#input-tags").hide();
    }

    function clikaddtags(tid) {
        $("#input-tags").remove("display").show();
        $("#input-value").data("id", tid);
        $("#input-but").attr("onclick", "addtags(" + tid + ")");
    }

    function clikModTypeName(tid) {
        $("#input-tags").remove("display").show();
        $("#input-but").attr("onclick", "modTypeName(" + tid + ")");
    }

    function modTypeName(tid) {
        var name = $("#input-value").val();
        $.ajax({
            "url": "/viptags/modTypeName/",
            "data": "id=" + tid + "&name=" + name,
            "type": "POST",
            "dataType": "json",
            "success": function (json) {
                if (json.state == 200) {
                    window.location.reload();
                } else {
                    alert("系统错误")
                }
            }
        })
    }

    function addtags(tid) {
        var name = $("#input-value").val();
        $.ajax({
            "url": "/viptags/addbos/",
            "data": "tid=" + tid + "&name=" + name,
            "type": "POST",
            "dataType": "json",
            "success": function (json) {
                if (json.state == 200) {
                    window.location.reload();
                } else {
                    alert("系统错误")
                }
            }
        })
    }

    function deltags(id) {
        $.ajax({
            "url": "/viptags/delbos/",
            "data": "id=" + id,
            "type": "POST",
            "dataType": "json",
            "success": function (json) {
                if (json.state == 200) {
                    window.location.reload();
                } else {
                    alert("系统错误")
                }
            }
        })
    }

    setTimeout(function () {
        issync();
    }, 1000);

    function issync() {
        var syn = true;
        if (bossyn.length != wxsyn.length - 1) {
            syn = false;
        }
        for (var i = 1; i < wxsyn.length; i++) {
            var bol = false;
            for (var j = 0; j < bossyn.length; j++) {

                if (bossyn[j] == wxsyn[i].name) {
                    console.log(wxsyn[i].name + ":" + bossyn[j]);
                    bol = true;
                }
            }
            if (!bol) {
                syn = false
            }
        }
        if (!syn) {
            $("#run").css("background", "#dba939");
        }

    }

    function sync() {
        for (var i = 0; i < bossyn.length; i++) {
            var bol = false;
            for (var j = 0; j < wxsyn.length; j++) {
                if (wxsyn[j].name == bossyn[i]) {
                    bol = true;
                }
            }
            if (!bol) {
                //wx添加
                AddTagsWxbacth(bossyn[i])
            }
        }

        for (var i = 0; i < wxsyn.length; i++) {
            var bol = false;
            for (var j = 0; j < bossyn.length; j++) {
                if (bossyn[j] == wxsyn[i].name) {
                    bol = true;
                }
            }
            if (!bol) {
                //wx删除
                delTagsWxbacth(wxsyn[i].id)
            }
        }
        $("#run").css("background", "#20ac27");
    }

    function AddTagsWxbacth(name) {

        $.ajax({
            "url": "/viptags/addwx/",
            "data": "name=" + name,
            "type": "POST",
            "dataType": "json",
            "success": function (json) {
                if (json.state == 200) {
                    window.location.reload();
                } else {
                    alert("系统错误")
                }
            }
        })

    }

    function delTagsWxbacth(id) {

        $.ajax({
            "url": "/viptags/delwx/",
            "data": "id=" + id,
            "type": "POST",
            "dataType": "json",
            "success": function (json) {
                if (json.state == 200) {
                    $("#wxxbq" + id).remove();
                    for (var i = 0; i < wxsyn.length; i++) {
                        if (id == wxsyn[i].id) {
                            wxsyn.splice(i);
                        }
                    }
                } else {
                    alert("系统错误")
                }
            }
        })
    }

    function delTagsWx(id) {
        if (!confirm("确定要删除吗？")) {
            return
        }
        $.ajax({
            "url": "/viptags/delwx/",
            "data": "id=" + id,
            "type": "POST",
            "dataType": "json",
            "success": function (json) {
                if (json.state == 200) {
                    $("#wxxbq" + id).remove();
                } else {
                    alert("系统错误")
                }
            }
        })
    }

    function getWXdata() {
        $.ajax({
            "url": "/viptags/getwechat/",
            "type": "POST",
            "dataType": "json",
            "success": function (json) {
                if (json.state == 200) {
                    var list = json.data;
                    for (var i = 0; i < list.typeid.length; i++) {
                        var html = '<div class="list">' +
                            '                <div class="label-title">' +
                            '                    <div id="wx_type_name#{id}">属性</div>' +
                            /*  '                    <div><input type="button" value="删除类型"></div>' +
                              '                    <div><input type="button" value="添加标签"></div>' +*/
                            '                    <hr>' +
                            '                </div>' +
                            '                <div class="label-value" id="wx_type_value#{id}">' +
                            '                </div>' +
                            '            </div>';
                        html = html.replace("#{id}", list.typeid[i]);
                        html = html.replace("#{id}", list.typeid[i]);
                        $("#left").append(html);
                    }

                    for (var i = 0; i < list.data.length; i++) {
                        var html = '<div id="wxxbq' + list.data[i].id + '"><span>' + list.data[i].name + '</span><span onclick="delTagsWx(' + list.data[i].id + ')"><i class="fa fa-times"></i></span></div>';
                        $("#wx_type_name" + list.data[i].typeid).html(list.data[i].type);
                        $("#wx_type_value" + list.data[i].typeid).prepend(html);
                    }
                    wxsyn = list.syn;
                    console.log(wxsyn)
                } else {
                    console.log("wechat数据错误");
                }
            }
        })
    }

    function getBOSdata() {
        $.ajax({
            "url": "/viptags/getbos/",
            "type": "POST",
            "dataType": "json",
            "success": function (json) {
                if (json.state == 200) {
                    var list = json.data.data;
                    for (var i = 0; i < list.length; i++) {
                        var id = list[i].typeid;
                        $("#bos_type_name" + id).html(list[i].type);
                        var html = '<div><span>' + list[i].name + '</span><span onclick="deltags(' + list[i].id + ')"><i class="fa fa-times"></i></span></div>';
                        $("#bos_type_value" + id).append(html);
                    }
                    bossyn = json.data.syn;
                    console.log(bossyn);
                } else {
                    console.log("bos数据错误");
                }
            }
        })
    }
</script>
<script>
    $("#e-exit").click(function () {
        $(document).ready(
            $.ajax({
                "url": "/backend/exit/",
                "type": "POST",
                "success": function () {
                    location.href = "login-system.html"
                }
            }))
    })
</script>

</html>